home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
c_lib.arc
/
PCDOSCMD.C
< prev
next >
Wrap
Text File
|
1990-08-09
|
3KB
|
88 lines
/**
*
* Name pcdoscmd -- Execute a DOS command
*
* Synopsis ercode = pcdoscmd(pcmd);
* int ercode Returned error code
* char *pcmd Command to execute
*
* Description PCDOSCMD invokes a secondary copy of the command
* processor to load and execute a DOS command. This is
* accomplished by making a call to PCEXEC (to load the
* command processor) passing the command as the command
* line. The function PCENVCHK returns the COMSPEC=
* parameters, which gives the path name for the command
* processor. If the command processor cannot be found,
* an error is returned.
*
* Returns ercode Returned status code. Values
* between -18 and 18 are codes returned
* from PCEXEC. Other value is:
* 19 - COMPSPEC= could not be found in
* the environment. This is an error
* returned from pcenvchk.
* 20 - Command processor could not be found
*
* Version 1.1 (C)Copyright Blaise Computing Inc. 1983, 1984
*
**/
#include <compiler.h>
#if LDATA
#define NULL 0L
#else
#define NULL 0
#endif
struct dreg
{
unsigned ax,bx,cx,dx,si,di,ds,es;
};
#define DOSREG struct dreg
int pcdoscmd(pcmd)
char *pcmd;
{
char *pcenvchk(),*pcomspec,*pdoscmd,*calloc();
int dos(),ercode;
DOSREG dos_reg;
#if CI201A & LDATA
unsigned long ptrtoabs();
#endif
pcomspec = pcenvchk("COMSPEC=",64);
if (pcomspec == NULL)
return(19); /* Problem with the environment */
/* Now make sure the file is there by calling function 4E (SFIRST) */
utinit(&dos_reg);
dos_reg.ax = 0x4e00;
#if LDATA
#if CI201A
dos_reg.ds = (unsigned)((ptrtoabs(pcomspec) & 0xffff0L) >> 4L);
dos_reg.dx = (unsigned)(ptrtoabs(pcomspec) & 0xfL);
#else
dos_reg.ds = (unsigned)(((long)(pcomspec) & 0xffff0L) >> 4L);
dos_reg.dx = (unsigned)((long)(pcomspec) & 0xfL);
#endif
#else
dos_reg.dx = (unsigned)pcomspec;
#endif
if (dos(&dos_reg))
return(20); /* Cannot find COMMAND.COM */
pdoscmd = calloc(128,1);
strcat(pdoscmd,"/C");
strcat(pdoscmd,pcmd);
strcat(pdoscmd,"\015");
ercode = pcexec(pcomspec,pdoscmd);
free(pcomspec);
free(pdoscmd);
return(ercode);
}